<?php

namespace App\Http\Requests;

class EVPIRequest extends FormRequest
{
    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'wechat_code'=>'required',
            'wechat_qrcode_url'=> 'mimes:jpeg,bmp,png,gif|dimensions:min_width=200,min_height=200',
            'bank_card'=>'required|regex:/^[0-9]{6,20}$/',
            'real_name'=>'required|min:2|max:10',
            'bank_name'=>'required|min:6|max:30',
        ];
    }

    public function messages()
    {
        return [
            'wechat_code.required'=>['error_code'=>'F009001','message'=>'微信号必须！'],
            'wechat_qrcode_url.mimes'=>['error_code'=>'F009002','message'=>'微信二维码必须是 jpeg, bmp, png, gif 格式的图片！'],
            'wechat_qrcode_url.dimensions'=>['error_code'=>'F009003','message'=>'微信二维码 清晰度不够，宽和高需要 200px 以上！'],
            'bank_card.required'=>['error_code'=>'F009004','message'=>'银行卡必须！'],
            'bank_card.regex'=>['error_code'=>'F009005','message'=>'银行卡位数不对！'],
            'real_name.required'=>['error_code'=>'F009006','message'=>'真实姓名必须！'],
            'real_name.max'=>['error_code'=>'F009007','message'=>'真实姓名最多 10 位！'],
            'real_name.min'=>['error_code'=>'F009008','message'=>'真实姓名至少 6 位！'],
            'bank_name.required'=>['error_code'=>'F009009','message'=>'开户地必须！'],
            'bank_name.min'=>['string'=>['error_code'=>'F009010','message'=>'开户地至少 6 位！']],
            'bank_name.max'=>['string'=>['error_code'=>'F009011','message'=>'开户地最多 30 位！']],
        ];
    }
}
